class TopItem extends egret.DisplayObjectContainer{


    private itemData:any = null;

    constructor(data:any){
        super();
        this.itemData = data;
        this.initView();
        this.anchorOffsetX = this.width/2;
        this.anchorOffsetY = this.height/2;
    }
    private initView():void{
        this.width = 160;
        //头像
        var headView = new eui.Image();
        headView.width = this.width;
        headView.height = this.width;
        headView.source = this.itemData.head_url;
        var shape = utils.drawRound(0, 0, this.width, this.width, 0x000, 10);
        this.addChild(shape);
        headView.mask = shape;
        this.addChild(headView);
        //头像边框
        var iconBorder = utils.createBitmapByName("icon_border");
        iconBorder.width = iconBorder.height = headView.width;
        this.addChild(iconBorder);

        var levelLabel = utils.createTextField({
            width:headView.width/2,
            height:30,
            x:headView.width/2,
            y:headView.height - 30,
            stroke:2,
            strokeColor:0x644205,
            textColor:0xFBE43C,
            size:20,
            italic:true,
            text:'Lv'+this.itemData.level_no
        });
        this.addChild(levelLabel);
        //昵称与背景
        var name_bg = utils.createBitmapByName('phb_name');
        name_bg.x = this.width/2 - name_bg.width/2;
        name_bg.y = headView.height + 60;
        this.addChild(name_bg);
        var name = utils.createTextField({
            width:name_bg.width,
            height:name_bg.height-10,
            x:name_bg.x,
            y:name_bg.y,
            textColor:0xFFFFFF,
            text:utils.getChar(this.itemData.nickname,18)
        });
        this.addChild(name);
        //积分
        let jf_box = utils.createSprite({
            width:this.width*1.1,
            height:name_bg.height * 0.8,
            y:name_bg.y + name_bg.height + 10,
            x:-this.width*0.05
        });
        jf_box.graphics.beginFill(0x42251a);
        jf_box.graphics.lineStyle(2,0x9D6425);
        jf_box.graphics.drawRoundRect(0,0,jf_box.width,jf_box.height,70,70);
        jf_box.graphics.endFill();
        this.addChild(jf_box);
        let jf = utils.createTextField({
            text:'积分:',
            textColor:0xedc05d,
            height:jf_box.height,
            x:10
        });
        jf_box.addChild(jf);
        let jf_num = utils.createTextField({
            width:jf_box.width - jf.width - 10,
            x:jf.width+jf.x,
            height:jf_box.height,
            textColor:0xFBBB11,
            text:this.itemData.total_score + '',
            bold:true
        });
        jf_box.addChild(jf_num);
    }
}